/*
 Navicat Premium Dump SQL

 Source Server         : 127.0.0.1
 Source Server Type    : MySQL
 Source Server Version : 50744 (5.7.44)
 Source Host           : 127.0.0.1:3306
 Source Schema         : smart_community

 Target Server Type    : MySQL
 Target Server Version : 50744 (5.7.44)
 File Encoding         : 65001

 Date: 08/09/2025 15:44:23
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for sc_owner
-- ----------------------------
DROP TABLE IF EXISTS `sc_owner`;
CREATE TABLE `sc_owner` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '业主ID',
  `owner_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '业主姓名',
  `id_card` varchar(18) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '身份证号',
  `user_id` bigint(20) DEFAULT NULL COMMENT '关联用户ID',
  `phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '联系电话',
  `email` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '邮箱地址',
  `gender` tinyint(4) DEFAULT '0' COMMENT '性别：0-未知，1-男，2-女',
  `birth_date` date DEFAULT NULL COMMENT '出生日期',
  `address` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '联系地址',
  `occupation` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '职业',
  `company` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '工作单位',
  `emergency_contact` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '紧急联系人',
  `emergency_phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '紧急联系电话',
  `remark` text COLLATE utf8mb4_unicode_ci COMMENT '备注信息',
  `status` tinyint(4) DEFAULT '1' COMMENT '状态：0-禁用，1-启用（遵循SystemStatusEnum标准）',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `create_by` bigint(20) DEFAULT NULL COMMENT '创建人ID',
  `update_by` bigint(20) DEFAULT NULL COMMENT '更新人ID',
  `version` int(11) DEFAULT '1' COMMENT '乐观锁版本号',
  `deleted` tinyint(4) DEFAULT '0' COMMENT '软删除标记：0-未删除，1-已删除（遵循SystemStatusEnum标准）',
  `owner_status` tinyint(4) DEFAULT '1' COMMENT '业主状态：0-未激活，1-已激活，2-已禁用',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id_card` (`id_card`),
  UNIQUE KEY `uk_user_id` (`user_id`),
  KEY `idx_id_card` (`id_card`),
  KEY `idx_phone` (`phone`),
  KEY `idx_status` (`status`),
  KEY `idx_create_time` (`create_time`),
  KEY `idx_deleted` (`deleted`),
  KEY `idx_owner_name_phone` (`owner_name`,`phone`),
  KEY `idx_owner_status_create_time` (`status`,`create_time`),
  KEY `idx_owner_status` (`owner_status`),
  KEY `idx_user_id` (`user_id`),
  CONSTRAINT `fk_owner_user` FOREIGN KEY (`user_id`) REFERENCES `sc_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='业主信息表';

-- ----------------------------
-- Records of sc_owner
-- ----------------------------
BEGIN;
INSERT INTO `sc_owner` (`id`, `owner_name`, `id_card`, `user_id`, `phone`, `email`, `gender`, `birth_date`, `address`, `occupation`, `company`, `emergency_contact`, `emergency_phone`, `remark`, `status`, `create_time`, `update_time`, `create_by`, `update_by`, `version`, `deleted`, `owner_status`) VALUES (1, '张三', '110101199001011234', NULL, '13800138000', 'zhangsan@example.com', 1, '1990-01-01', '北京市朝阳区xxx街道xxx小区', '工程师', '某某科技有限公司', '李四', '13900139000', '主要业主，联系方式畅通', 1, '2025-08-20 01:49:52', '2025-08-20 01:49:52', 1, 1, 1, 0, 1);
INSERT INTO `sc_owner` (`id`, `owner_name`, `id_card`, `user_id`, `phone`, `email`, `gender`, `birth_date`, `address`, `occupation`, `company`, `emergency_contact`, `emergency_phone`, `remark`, `status`, `create_time`, `update_time`, `create_by`, `update_by`, `version`, `deleted`, `owner_status`) VALUES (2, '李四', '110101199002021234', NULL, '13800138001', 'lisi@example.com', 2, '1990-02-02', '北京市海淀区xxx街道xxx小区', '设计师', '某某设计公司', '王五', '13900139001', '共有产权业主', 1, '2025-08-20 01:49:52', '2025-08-20 01:49:52', 1, 1, 1, 0, 1);
INSERT INTO `sc_owner` (`id`, `owner_name`, `id_card`, `user_id`, `phone`, `email`, `gender`, `birth_date`, `address`, `occupation`, `company`, `emergency_contact`, `emergency_phone`, `remark`, `status`, `create_time`, `update_time`, `create_by`, `update_by`, `version`, `deleted`, `owner_status`) VALUES (3, '王五', '110101199003031234', NULL, '13800138002', 'wangwu@example.com', 1, '1990-03-03', '北京市西城区xxx街道xxx小区', '教师', '某某学校', '赵六', '13900139002', '部分产权业主', 1, '2025-08-20 01:49:52', '2025-08-20 01:49:52', 1, 1, 1, 0, 1);
INSERT INTO `sc_owner` (`id`, `owner_name`, `id_card`, `user_id`, `phone`, `email`, `gender`, `birth_date`, `address`, `occupation`, `company`, `emergency_contact`, `emergency_phone`, `remark`, `status`, `create_time`, `update_time`, `create_by`, `update_by`, `version`, `deleted`, `owner_status`) VALUES (4, '赵六', '110101199004041234', NULL, '13800138003', 'zhaoliu@example.com', 2, '1990-04-04', '北京市东城区xxx街道xxx小区', '医生', '某某医院', '钱七', '13900139003', '投资型业主', 1, '2025-08-20 01:49:52', '2025-08-20 01:49:52', 1, 1, 1, 0, 1);
INSERT INTO `sc_owner` (`id`, `owner_name`, `id_card`, `user_id`, `phone`, `email`, `gender`, `birth_date`, `address`, `occupation`, `company`, `emergency_contact`, `emergency_phone`, `remark`, `status`, `create_time`, `update_time`, `create_by`, `update_by`, `version`, `deleted`, `owner_status`) VALUES (5, '钱七', '110101199005051234', NULL, '13800138004', 'qianqi@example.com', 1, '1990-05-05', '北京市丰台区xxx街道xxx小区', '律师', '某某律师事务所', '孙八', '13900139004', '自住型业主', 1, '2025-08-20 01:49:52', '2025-08-20 01:49:52', 1, 1, 1, 0, 1);
INSERT INTO `sc_owner` (`id`, `owner_name`, `id_card`, `user_id`, `phone`, `email`, `gender`, `birth_date`, `address`, `occupation`, `company`, `emergency_contact`, `emergency_phone`, `remark`, `status`, `create_time`, `update_time`, `create_by`, `update_by`, `version`, `deleted`, `owner_status`) VALUES (6, '测试业主4', '110101199001011237', NULL, '13800138999', 'test4@example.com', 1, '1990-01-01', '测试地址4', '测试职业4', '测试公司4', '紧急联系人4', '13900139999', NULL, 1, '2025-08-22 12:13:35', '2025-08-22 05:21:41', 24, 24, 1, 1, 1);
INSERT INTO `sc_owner` (`id`, `owner_name`, `id_card`, `user_id`, `phone`, `email`, `gender`, `birth_date`, `address`, `occupation`, `company`, `emergency_contact`, `emergency_phone`, `remark`, `status`, `create_time`, `update_time`, `create_by`, `update_by`, `version`, `deleted`, `owner_status`) VALUES (7, '进口量', '330184198511111111', 41, '13111111111', NULL, 1, '2025-08-18', '111111', '111', '111111', '的萨芬', '13111111112', '111', 1, '2025-08-22 13:19:57', '2025-08-28 08:07:04', 35, 35, 2, 0, 1);
INSERT INTO `sc_owner` (`id`, `owner_name`, `id_card`, `user_id`, `phone`, `email`, `gender`, `birth_date`, `address`, `occupation`, `company`, `emergency_contact`, `emergency_phone`, `remark`, `status`, `create_time`, `update_time`, `create_by`, `update_by`, `version`, `deleted`, `owner_status`) VALUES (8, '毛哥', '330184201611071815', 31, '15868171868', '19558156907@139.com', 2, '2016-11-07', NULL, NULL, NULL, NULL, NULL, '新手机号：19558156907', 1, '2025-08-24 19:38:09', '2025-08-28 08:07:04', 35, 42, 2, 0, 1);
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
